/*
 * @Author: 杨三炮
 * @Date: 2021-11-18 20:05:21
 * @LastEditors: 杨三炮
 * @LastEditTime: 2021-11-24 13:00:22
 * @FilePath: \node\node\routers\users.js
 */
const express = require('express')
const router = express()
const passport = require('passport')
const user = require('../dao/users_dao')

router.get('/', (req, res) => res.send('进入user路由'))
//登录
router.post('/login', (req, res) => {
    user.Login(req, res)
})

//分页获取type类型数据
router.get('/getUser', passport.authenticate('jwt', { session: false }), (req, res) => {
    user.getUser(req, res)
})
//根据id删除用户
router.delete('/delUserdata', passport.authenticate('jwt', { session: false }), (req, res) => {
    if (req.query.u_id == '1000') return res.status(404).json('不能删除管理员')
    user.delUserdata(req, res)
})
//更新用户数据
router.post('/upUserdata', passport.authenticate('jwt', { session: false }), (req, res) => {
    user.upUserdata(req, res)
})
//更新or插入数据
router.post('/setXlsxData', passport.authenticate('jwt', { session: false }), (req, res) => {
    user.setXlsxData(req, res)
})

//修改密码
router.post('/upPwd', passport.authenticate('jwt', { session: false }), (req, res) => {
    user.upPwd(req, res)
})
router.get('/getUserInfo', passport.authenticate('jwt', { session: false }), (req, res) => {
    user.getUserInfo(req, res)
})




module.exports = router